//main.cpp
#include <iostream>
#include "include/pthread.h"
//#include <winbase.h>
#include <windows.h>
using namespace std;

struct MSG_USER
{
	int i;
};

void* Function1(void* Param)
{
	MSG_USER* pi = (MSG_USER*)Param;
	cout<<pi->i<<endl;
	pthread_t myid = pthread_self();
	/*while(1)
	{
		cout<<"thread id = "<<myid.x<<endl;
		Sleep(4000);
	}*/
	cout<<"thread1 id = "<<myid.x<<endl;
	delete pi;
	pi = NULL;
	return NULL;
}

void* Function2(void* Param)
{
	MSG_USER* pi = (MSG_USER*)Param;
	cout<<pi->i<<endl;
	pthread_t myid = pthread_self();
	/*while(1)
	{
		cout<<"thread id = "<<myid.x<<endl;
		Sleep(4000);
	}*/
	cout<<"thread2 id = "<<myid.x<<endl;
	delete pi;
	pi = NULL;
	return NULL;
}


int main()
{
	pthread_t pid1;
	pthread_t pid2;
	MSG_USER* msg1 = new MSG_USER;
	MSG_USER* msg2 = new MSG_USER;
	msg1->i = 1;
	msg2->i = 2;
	pthread_create(&pid1, NULL, Function1, msg1);
	//Sleep(2000);
	pthread_create(&pid2, NULL, Function2, msg2);
// 	while(1)
// 	{
// 		cout<<"In father process."<<endl;
// 		Sleep(2000);
// 	}
	cin.get();
	return 0;
}
